<template>
	<view class="container">
		<view class="search">
			<u-search placeholder="请输入搜索网点" v-model="keyword" height="68rpx" :showAction="true" searchIconSize="38"
			:actionStyle="actionStyle" @change="search" @custom="search" @search="search"
			></u-search>
			
		</view>
		<view class="list">
			<scroll-view scroll-y="true" class="scrolly">
				<view class="listin" @click="toback(item.id,item.outletname)" v-for="(item,index) in list_data" :key="index">
					<text>{{item.outletname}}</text>
					<text>{{item.province+' '+item.city+' '+item.area+' '+item.address}}</text>
				</view>
			</scroll-view>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword:'',
				mydata:'',
				list:'',
				list_data:'',
				page:1,
				startid:'',
				endid:'',
				
				endid:'',
				actionStyle:{
					background:"#1890FF",
					color:"#fff",
					padding:'10rpx 30rpx'
				}
			};
		},
		onShow() {
			this.list_data=''
			this.getlist()
		},
	onLoad(option) {
		this.startid=option.sid
		this.endid=option.eid
		
	},
	onUnload() {
		uni.$off("updateData")
	},
		methods:{
			//搜索
			search(){
			this.list_data=''
				this.getlist()
			},
			//途径列表
			getlist(){
				this.$lists({
					page:this.page,
					outletname:this.keyword
				}).then(res=>{
					this.list=res.data
					this.list_data=[...this.list_data,...res.data.data]
					if(res.code!=1){
						this.$toast(res.msg)
					}
				})
			},
			toback(id,outletname){
				this.mydata={outlet_id:id,outlet_name:outletname}
				if(id==this.startid){
					this.$toast("不能与起点一致")
					return false
				}
				if(id==this.endid){
					this.$toast("不能与终点一致")
					return false
				}
				uni.$emit('updateData', JSON.stringify(this.mydata))
								uni.navigateBack({
									delta: 1
								})
								

			}
		}
	}
</script>

<style lang="scss">
page{
	background: #fff;
}
.container{
	.search{
		padding: 20rpx;
		display: flex;
	}
	.list{
		.scrolly{
			height: 1300rpx;
		}
		
		.listin{
			padding: 30rpx;
			height: 90rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			// border: 1px solid #ccc;
			text{
				font-size: 32rpx;
				color: #000;
			}
		}
	}
}
</style>
